package gui;

import java.awt.Color;
import java.awt.Rectangle;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JTextField;

import client.Client;
import client.quit;

public class MainEmployee extends JFrame{
	private JPanel mainform = null;
	private MainPanel MP;
	private JLabel jLabelWelcome = null;
	private JButton jButtonCatalog = null;
	JButton jButtonQuestion = null;
	private JButton jButtonExit = null;
	private JButton jButtonHelp = null;
	private JButton jButtoncomplaint = null;
	private JButton jButtoncomplaintfollw = null;
	
	private JLabel jLabelLogIn = null;
	JTextField jTextFieldloginInfo = null;
	JLabel jLabelComplaints = null;
	JTextField jTextFieldComplaintsNum = null;
	JButton jButtonGoToComplaints = null;
	private JLabel jLabelBackground = null;
	JButton jButtonReports = null;
	final public static int DEFAULT_PORT = 5555;
	private String host = MainPanel.ip;
	private Client c = new Client(host,DEFAULT_PORT);
	public MainEmployee() {
		super();
		initialize();
	}

	void quit (){
		String userName;
		userName = MainPanel.Userinfo[3];
		quit q = new quit(userName);
		q.closeWindow();
	}
	/**
	 * 
	 */
	private void initialize() {
		this.setSize(1000, 720);
		this.setContentPane(MainEmployeeForm());
		this.setTitle("MAIN SCREEN");	
		this.addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(java.awt.event.WindowEvent e) {
				Client client2 = new Client(host,DEFAULT_PORT);
				client2.accept(gui.MainPanel.Userinfo);										
				System.exit(0);				
				
			}
		});
		
		
	}
	private JPanel MainEmployeeForm() {
		if (mainform == null) {
			ImageIcon imageBack = new ImageIcon("4.jpg");
			ImageIcon welcome = new ImageIcon("welcome1.gif");	
			jLabelBackground = new JLabel();
			jLabelBackground.setIcon(imageBack);
			jLabelBackground.setBounds(new Rectangle(1, -1, 990, 687));						 							
			
			jLabelLogIn = new JLabel();
			jLabelLogIn.setBounds(new Rectangle(285, 616, 168, 35));
			jLabelLogIn.setText("YOUR LAST LOGIN WAS ON:");
			jLabelWelcome = new JLabel();
			jLabelWelcome.setIcon(welcome);
			jLabelWelcome.setBounds(new Rectangle(223, 14, 504, 157));			
			mainform = new JPanel();
			mainform.setLayout(null);
			mainform.setBackground(Color.CYAN); 
			mainform.add(jLabelWelcome, null);
			mainform.add(getJButtonCatalog(), null);
			mainform.add(getJButtonQuestion(), null);
			mainform.add(getJButtonExit(), null);
			mainform.add(getJButtonHelp(), null);
			mainform.add(jLabelLogIn, null);
			mainform.add(getJButtoncomplaint(), null);
			mainform.add(getJButtoncomplaintfollw(), null);
			mainform.add(getJTextFieldloginInfo(), null);
			mainform.add(getJButtonReports(), null);
			mainform.add(jLabelBackground, null);
			
			 


		}
		return mainform; 
	}

	/**
	 * This method initializes jButtonCatalog	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonCatalog() {
		if (jButtonCatalog == null) {
			jButtonCatalog = new JButton();
			ImageIcon imageCatalog = new ImageIcon("catalog.jpg");
			jButtonCatalog.setIcon(imageCatalog);
			jButtonCatalog.setBounds(new Rectangle(348, 210, 304, 74));
		//	jButtonCatalog.setText("CATALOG OPTIONS");
			jButtonCatalog.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					
					EmployeeCatalogOP ECOPFrame = new EmployeeCatalogOP();
					ECOPFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
					ECOPFrame.setSize( 1000,720 ); // set frame size
					ECOPFrame.setResizable(true);
					ECOPFrame.setVisible( true ); // display frame
					MainEmployee.this.dispose();
				    
				    
				}
			});
		}
		return jButtonCatalog;
	}

	/**
	 * This method initializes jButtonOrder	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonQuestion() {
		if (jButtonQuestion == null) {
			jButtonQuestion = new JButton();
			ImageIcon imageCatalog = new ImageIcon("question.jpg");
			jButtonQuestion.setIcon(imageCatalog);
			jButtonQuestion.setBounds(new Rectangle(100, 180, 179, 140));
			jButtonQuestion.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					
					Questionnare QFrame = new Questionnare();
					QFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
					QFrame.setSize( 1000,720 ); // set frame size
					QFrame.setResizable(true);
					QFrame.setVisible( true ); // display frame
					MainEmployee.this.dispose();
				    
				    
				}
			});
		}
		return jButtonQuestion;
	}

	/**
	 * This method initializes jButtonExit	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonExit() {
		if (jButtonExit == null) {
			jButtonExit = new JButton();
			ImageIcon imageCancel = new ImageIcon("Button_cancel.png");
			jButtonExit.setIcon(imageCancel);
			jButtonExit.setBounds(new Rectangle(816, 564, 97, 93));
		//	jButtonExit.setText("EXIT");
			jButtonExit.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					
					ExitFrame EFrame = new ExitFrame();
				    EFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
				    EFrame.setSize( 300,200 ); // set frame size
				    EFrame.setResizable(true);
				    EFrame.setVisible( true ); // display frame
		
				    
				    
				}
			});
		}
		return jButtonExit;
	}

	/**
	 * This method initializes jButtonHelp	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonHelp() {
		if (jButtonHelp == null) {
			jButtonHelp = new JButton();
			ImageIcon imageHelp = new ImageIcon("help.jpg");
			jButtonHelp.setIcon(imageHelp);
			jButtonHelp.setBounds(new Rectangle(62, 572, 84, 82));
			jButtonHelp.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					HelpFrame HFrame = new HelpFrame();

					HFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
					HFrame.setSize( 600,720 ); // set frame size
					HFrame.setResizable(false);
					HFrame.setVisible( true ); // display frame
				}
			});
		}
		return jButtonHelp;
	}

	/**
	 * This method initializes jTextFieldloginInfo	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldloginInfo() {
		if (jTextFieldloginInfo == null) {
			jTextFieldloginInfo = new JTextField();
			jTextFieldloginInfo.setBounds(new Rectangle(465, 616, 137, 35));
			jTextFieldloginInfo.setText(MainPanel.Userinfo[5]);
		}
		return jTextFieldloginInfo;
	}

	/**
	 * This method initializes jTextFieldComplaintsNum	
	 * 	
	 * @return javax.swing.JTextField	
	

	/**
	 * This method initializes jButtonReports	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonReports() {
		if (jButtonReports == null) {
			jButtonReports = new JButton();
			ImageIcon imageReports = new ImageIcon("report-icon.jpg");
			jButtonReports.setIcon(imageReports);
			jButtonReports.setBounds(new Rectangle(721, 180, 179, 140));
			jButtonReports.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					Report RFrame = new Report();					
					RFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
					RFrame.setSize(1000,720 ); // set frame size
					RFrame.setResizable(false);
					RFrame.setVisible( true ); // display frame
					MainEmployee.this.dispose();
				}
			});
		}
		return jButtonReports;
	}
	
	
	private JButton getJButtoncomplaint() {
		if (jButtoncomplaint == null) {
			jButtoncomplaint = new JButton();
			jButtoncomplaint.setBounds(new Rectangle(410, 333, 178, 125));
			ImageIcon imageComplaint = new ImageIcon("compalint.png");
			jButtoncomplaint.setIcon(imageComplaint);
			jButtoncomplaint.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					//order need to get client as object 
					
					Complaint com = new Complaint();
					
					com.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
					com.setSize(1000,720 ); // set frame size
					com.setResizable(false);
					com.setVisible( true ); // display frame
					MainEmployee.this.dispose();
				    
				    
				}
			});
		}
		return jButtoncomplaint;
	}
	
	private JButton getJButtoncomplaintfollw() {
			
			if (jButtoncomplaintfollw == null) {
			jButtoncomplaintfollw = new JButton();
			jButtoncomplaintfollw.setBounds(new Rectangle(354, 475, 292, 71));
			
			ImageIcon imageFComplaint = new ImageIcon("pictuer/comstat.jpg");
			jButtoncomplaintfollw.setIcon(imageFComplaint);
		
			jButtoncomplaintfollw.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					//order need to get client as object 
					
					Followcom com = new Followcom();
					
					com.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
					com.setSize(1000,720 ); // set frame size
					com.setResizable(false);
					com.setVisible( true ); // display frame
					MainEmployee.this.dispose();
				    
				    
				}
			});
		}
		return jButtoncomplaintfollw;
	}
	
	
}  //  @jve:decl-index=0:visual-constraint="26,28"
